/**
 * ServerScoket.java
 * Server.server
 *
 * Function�� TODO 
 *
 *   ver     date      		author
 * ��������������������������������������������������������������������
 *   		 Aug 30, 2012 5:12:09 PM 	tengfei.zhu
 *
 * Copyright (c) 2012, TNT All Rights Reserved.
 */
package Server.server;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

public class Servers {
	private static ServerSocket ss;
	private  static Socket sc;
	
	static{
		try {
			ss = new ServerSocket(9392);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	//����˿��Ƿ�������
	public void isConnection(){
		
	}
	
	
	public void getClientR(){
		try {
			sc = ss.accept();
			String addressId = sc.getInetAddress().getHostAddress();
			System.out.println(addressId);
			InputStream in = sc.getInputStream();
			byte[] b = new byte[1024];
			StringBuffer sb = new StringBuffer();
			while(in.read(b)!= -1){
				sb.append(new String(b, "UTF-8"));
			}
			System.out.println(sb.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args){
		new Servers().getClientR();
	}
	
	
}
